"use strict";
cc._RF.push(module, '08120V+s/BEy7S5VFMjcwUH', 'TT_XHR');
// Script/Util/Network/XHR/TT_XHR.ts

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TT_XHR = void 0;
class TT_XHR {
    /**
     * wx get json
     * @param url
     * @param success
     * @param fail
     */
    static getJSON(url, success, fail) {
        tt.request({
            url: url,
            method: "GET",
            responseType: "text",
            success: function (res) {
                if (success)
                    success(res.data);
            },
            fail: function (res) {
                //console.error('wx get json fail');
                if (fail)
                    fail(res);
            },
        });
    }
    static post(url, data, success, fail) {
        tt.request({
            url: url,
            method: "Post",
            responseType: "text",
            data: data,
            success: function (res) {
                if (success)
                    success(res.data);
            },
            fail: function (res) {
                //console.error('wx get json fail');
                if (fail)
                    fail(res);
            },
        });
    }
    static post_Async(url, data) {
        return new Promise((resolve, reject) => {
            tt.request({
                url: url,
                method: "Post",
                responseType: "text",
                data: data,
                success: function (res) {
                    if (resolve)
                        resolve(res.data);
                },
                fail: function (res) {
                    //console.error('wx get json fail');
                    if (reject)
                        reject(res);
                },
            });
        });
    }
    /**
     * wx get json 使用 Promise
     * @param url
     */
    static getJSON_Async(url) {
        return new Promise((resolve, reject) => {
            tt.request({
                url: url,
                method: "GET",
                responseType: "text",
                success: function (res) {
                    resolve(res.data.toString());
                },
                fail: function (res) {
                    //console.error('wx get json fail');
                    reject(res);
                },
            });
        });
    }
}
exports.TT_XHR = TT_XHR;

cc._RF.pop();